/*************************************************************************

    SlkAction.h

    Version 7.51

    This module contains the public declarations.

    Copyright (c) 2002-2014  SLK Systems, all rights reserved.
    
*************************************************************************/

#ifndef _SLKACTION_H
#define _SLKACTION_H

#include "tree.h"
#include "SlkToken.h"
#include "SlkConstants.h"

#define PRIVATE static
#define PUBLIC
#define INSTANCE_METHOD static

#define STACKSIZE   256 

typedef struct _node2 
{ 
    double    item;
    struct
    _node2   *left,
             *right;
} node2_t;

typedef struct _stack2
{
    node2_t  **top ,
             **end ,
              *start [ STACKSIZE ];
} stack2_t;

typedef struct _stack3
{
    double   *top ,
             *end ,
              start [ STACKSIZE ];
} stack3_t;

#undef  SELF
#define SELF    struct _action

typedef struct _action
{
    tree_t     tree;                        // inherited instance
    peeker_t  *peeker; 
    node2_t   *abstract_root;
    stack2_t   abstract_stack;
    stack3_t   semantic_stack;
    double     answer;

    void  (*execute) ( SELF *, slk_size_t action_number );
    void  (*reduce) ( tree_t *id, slk_size_t production_number );
    void  (*predict) ( tree_t *id, slk_size_t production_number );
    void  (*state) ( SELF *, slk_size_t  number );

    void  (*show_tree) ( tree_t *id );
    void  (*show_parse_derivation) ( tree_t *id );
    double (*post_order) ( SELF  *d );
                         
} action_t, SlkAction;

#undef reduce
#undef predict
#undef show_tree
#undef show_parse_derivation

#define reduce(self,a)           (*self).reduce(&(*self).tree,a)
#define predict(self,a)          (*self).predict(&(*self).tree,a)

#define show_tree(self)          (*self).show_tree(&(*self).tree)
#define show_parse_derivation(self)   (*self).show_parse_derivation(&(*self).tree)

#define execute(self,a)          (*self).execute(self,a)
#define state(self,a)            (*self).state(self,a)
#define post_order(self)         (*self).post_order(self) 

PUBLIC
void
InitializeAction ( action_t  *action,
                   int        display,
                   peeker_t  *peeker ); 

#endif

